package com.dzh.dzhhub.controller;

import com.dzh.dzhhub.common.Result;
import com.dzh.dzhhub.entity.User;
import com.dzh.dzhhub.service.LoginService;
import com.dzh.dzhhub.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.ServletResponse;

/**
 * @author DZHooo
 * @version 1.0
 * @date 2021/11/16 11:30
 * @description: TODO
 */

@RestController
@RequestMapping("/login")
public class LoginController {

    @Autowired
    private LoginService loginService;

    @Autowired
    private UserService userService;

    @PostMapping("/auth")
    public Result authLogin(String username, String password, ServletResponse response) {
        return loginService.authLogin(username, password,response);
    }

    @PostMapping("/getInfo")
    public Result getInfo() {
        return loginService.getInfo();
    }

    @PostMapping("/logout")
    public Result logout(String username) {
        return loginService.logout(username);
    }


    //test
//    @PostMapping("/getUser")
//    public Result getUser(String username) {
//        User user = userService.getUser(username);
//        if(user==null) return Result.error("401","getUser()不行！");
//        return Result.success(user);
//    }


}
